module.exports = function(app){
    app.controller('loginCtrl', function ($scope, $http, $location) {
        $scope.loginData = {
            name: '',
            password: '',
            err_msg: ''
        };
        $scope.login = function () {
    
            $http({
                method: 'POST',
                url: 'api/merchant/login',
                data: $scope.loginData
            }).then(function successCallback(response) {
                console.log(response);
                if (response.data.status == true) {
                    alert('登录成功');
                    window.location.href = 'manager.html';
                } else {
                    console.log(response)
                    err_msg = response.data.message;
                    alert(err_msg);
                }
            }, function errorCallback(response) {
                alert("异常");
            });
    
        };
    
        $scope.test = function () {
            // $location.path('https://www.baidu.com');
            window.location.href = 'manager.html';
        }
    })
}